﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using ConstructionBidOnline.Biz;

public partial class admin_forgetpassword : System.Web.UI.Page
{
    #region Event Handlers

    #region Page Load

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    #endregion 

    #region Save Button Click

    protected void btnFPSubmit_Click(object sender, ImageClickEventArgs e)
    {
        SubAdmin subadmin = SubAdmin.GetUserByUserLogin(txtemailaddress.Text);
        if (subadmin != null)
        {
            string newpassword = SubAdmin.CreateRandomPassword(7);
            string emailfeedback;
            bool emailsend = ConstructionBidOnline.MailUtils.SendEmail(subadmin.EmailAddress, subadmin.FirstName + " " + subadmin.LastName, "Password Changed...", "This is an system generated mail with respect to the request for your password change for the ConstructionBidOnline account.<br><br>Your user name is : " + subadmin.EmailAddress + "<br><br>Your new password is : " + newpassword + "<br><br>This is a system generated mail, so please dont reply to this mail.", out emailfeedback);
            subadmin.Password = SubAdmin.HashPassword(newpassword);
            subadmin.IsPasswordChangeRequired = true;
            subadmin.LastPasswordChangedDate = DateTime.Now;
            SubAdmin.Update(subadmin);
            lblerror.Visible = true;
            lblerror.Text = "Your password is reset and a mail is sent to your email address with respect to the same.";
        
            
        }
        else
        {
            lblerror.Visible = true;
            lblerror.Text = "The email address you entered is not registered to our site";
        }
    }

    #endregion 

    #endregion
}
